<template>
    <div id="app">
        <div id="nav">
            <router-view v-if="isRouterAlive"/>
        </div>
    </div>
</template>

<script>
    export default {
        name: "App",
        provide() {    //父组件中通过provide来提供变量，在子组件中通过inject来注入变量。
            return {
                reload: this.reload
            }
        },
        data() {
            return {
                isRouterAlive: true                    //控制视图是否显示的变量
            }
        },
        methods: {
            reload() {
                this.isRouterAlive = false;            //先关闭，
                this.$nextTick(function () {
                    this.isRouterAlive = true;         //再打开
                })
            }
        },
        mounted() {
            const oScript = document.createElement('script');
            oScript.type = 'text/javascript';
            oScript.src = '//g.alicdn.com/sd/smartCaptcha/0.0.1/index.js';
            document.body.appendChild(oScript);
        }

    };
</script>

<style lang="scss">
    #app {
        font-family: Avenir, Helvetica, Arial, sans-serif;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        color: #2c3e50;
    }

    #nav {
        a {
            font-weight: bold;
            color: #2c3e50;
            &.router-link-exact-active {
                color: #42b983;
            }
        }
    }

    /*去除边框*/
    * {

    }
    html{
        margin: 0;
        padding: 0;
    }

</style>
